<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('Document')" />
    <style>

    </style>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <div class="col-sm-12">
        <form class="form-horizontal m" id="form-approve-edit">
            <input name="reqId" th:value="${reqId}" type="hidden">
            <input id="approveBy" name="approveBy" th:value="${approveBy}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">状态：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="reqStatus" id="reqStatus">
                        <option th:value="${@dict.getValue('sys_request_status','pending QA approval')}" selected>Pending approval</option>
                        <option th:value="${@dict.getValue('sys_request_status','Completed')}">Approved</option>
                        <option th:value="${@dict.getValue('sys_request_status','Reject')}">Not Approved</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">Comment：</label>
                <div class="col-sm-8">
                    <textarea name="comment" id="approveComment" class="form-control" maxlength="999" rows="4"></textarea>
                </div>
            </div>
        </form>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "system/request2";

    $("#form-approve-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {

        if ($.validate.form()) {
            // 确认提交提醒，附带提交数据
            $.modal.confirm(generateConfirmContent() , function() {
                // 提交表单数据
                var data = $('#form-approve-edit').serializeArray();
                $.operate.save(prefix + "/approveQA", data);
            });
        }
    }

    function generateConfirmContent() {
        var approver = $('#approveBy').val();
        var approveStatus = $('#reqStatus option:selected').text();
        var reason = $('#approveComment').val();
        return `<div style="padding: 10px;">
            <p><strong>审批人：</strong>${approver}</p>
            <p><strong>状态：</strong>${approveStatus}</p>
            <p><strong>意见：</strong>${reason}</p>
            <p style="color:red;">请确认以上信息无误后提交。</p>
        </div>`;
    }
</script>
</body>
</html>